<template>
	<view class="h_100 bg-white" @click="selectShow = false">
		<u-sticky :offsetTop="offsetTop">
			<view class="head_box bg_main p-2">
				<view class="head_select bg-white flex justify-center" @click.stop="selectShow = !selectShow">
					<text class="tit h6 c_6 px-1 text_hidden1 font_24">{{ selectVal }}</text>
					<view class="down_icon"><u-icon name="arrow-down-fill" color="#999999" size="10"></u-icon></view>
				</view>
				<view class="select_box bg-white shadow text-center py-1" v-if="selectShow">
					<view class="font_24 py" v-for="(item, index) of selectList" :key="index" @click.stop="checkChange(item, index)">{{ item }}</view>
				</view>
			</view>
		</u-sticky>
		<view class=" p-2">
			<view v-if="list.length <= 0" class="p-2 mt-3" style="margin: 100rpx auto;">
				<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无询价信息"></u-empty>
			</view>
			<view class="price_box mt-1 mb-3" v-for="item of list" :key="item.id">
				<view class="title py-1 h6 text-white text-center">{{ item.sign_company }}</view>
				<view class="cont_box py-2">
					<view class="pl-5">
						<view class="h6">
							<text class="font-weight-bold">产品：</text>
							{{ item.product_model || '' }}
						</view>
						<view class="h6">
							<text class="font-weight-bold">类型：</text>
							{{ item.form_sign_name || '' }}
						</view>
						<view class="h6">
							<text class="font-weight-bold">时间：</text>
							{{ item.add_time || '' }}
						</view>
						<view class="h6">
							<text class="font-weight-bold">状态：</text>
							<text>{{ item.is_type == 1 ? '进行中' : '已完成' }}</text>
						</view>
					</view>
					<view class="btn_box mt-3">
						<button class="text-white h6" @click="goPages('/subPages/my/list/enquiry/detail?id=' + item.id + '&ismy=' + ismy)">查看</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getWapAdvisoryList } from '@/api/my/enquiry.js';
export default {
	props: {
		offsetTop: {
			type: String,
			default() {
				return '0';
			}
		},
		ismy: {
			type: Boolean,
			default: false
		}
	},
	data() {
		return {
			selectList: ['全部', '进行中', '已完成'],
			selectShow: false,
			selectVal: '全部',
			isType: '',
			list: []
		};
	},
	created() {
		this.getInfo();
	},
	methods: {
		checkChange(val, idx) {
			this.selectVal = val;
			this.isType = idx;
			this.getInfo();
		},
		getInfo() {
			// 我的询价
			let msg = {
				token: uni.getStorageSync('userInfo').token || '',
				is_type: this.isType
			};
			// 询价管理
			if (this.ismy) {
				msg = {
					...msg,
					uid: uni.getStorageSync('userInfo').userId || ''
				};
			}
			getWapAdvisoryList(msg)
				.then(res => {
					// console.log(res);
					this.selectShow = false;
					if (res.code == 0) {
						this.list = res.data.data;
					} else {
						uni.$u.toast(res.msg);
					}
				})
				.catch(err => {
					console.log('获取我的询价列表失败', err);
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.head_box {
	height: 92rpx;
	.head_select {
		position: relative;
		.down_icon {
			position: absolute;
			right: 10rpx;
			top: 10rpx;
		}
	}
	.select_box {
		border-top: 1px solid #f2f2f2;
	}
}

.price_box {
	.title {
		background-color: #c0c0c0;
	}
	.cont_box {
		background-color: #f2f2f2;
	}
	.btn_box {
		button {
			width: 300rpx;
			height: 56rpx;
			background: linear-gradient(-26deg, #cf1526, #d73342);
			box-shadow: 0px 0px 2px 0px rgba(195, 195, 195, 0.5);
			line-height: 56rpx;
		}
	}
}
</style>
